#include"UdpServer.hpp"
#include<memory>
#include<cstdio>
#include<string>
//"0.0.0.0"点分十进制字符串风格的IP地址

void Usage(const char *str)
{
     printf("\nUsage: %s port[1024+]\n\n", str);
}
std::string Handler(const std::string &str)
{
    std::string res = "server get a message: ";
    res += str;
    std::cout << res << std::endl;

    return res;
}
//ExecuteCommand

// ./udpserver port
int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(0);
    }
    uint16_t port = std::stoi(argv[1]);
    std::unique_ptr<UdpServer> server(new UdpServer(port));
    server->Init();
    server->Run(Handler);

    return 0;
}
